package com.jiuyou.clientController.weeklyReport;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.weeklyReport.domain.WeeklyReport;
import com.ruoyi.weeklyReport.service.IWeeklyReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 周报简报Controller
 *
 * @author ruoyi
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/client/weeklyReport")
public class ClientWeeklyReportController extends BaseController
{
    @Autowired
    private IWeeklyReportService weeklyReportService;

    /**
     * 查询周报简报列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WeeklyReport weeklyReport)
    {
        startPage();
        List<WeeklyReport> list = weeklyReportService.selectWeeklyReportList(weeklyReport);
        return getDataTable(list);
    }

    /**
     * 导出周报简报列表
     */
    @Log(title = "周报简报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WeeklyReport weeklyReport)
    {
        List<WeeklyReport> list = weeklyReportService.selectWeeklyReportList(weeklyReport);
        ExcelUtil<WeeklyReport> util = new ExcelUtil<WeeklyReport>(WeeklyReport.class);
        return util.exportExcel(list, "周报简报数据");
    }

    /**
     * 获取周报简报详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(weeklyReportService.selectWeeklyReportById(id));
    }

    /**
     * 新增周报简报
     */
    @Log(title = "周报简报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WeeklyReport weeklyReport)
    {
        return toAjax(weeklyReportService.insertWeeklyReport(weeklyReport));
    }

    /**
     * 修改周报简报
     */
    @Log(title = "周报简报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WeeklyReport weeklyReport)
    {
        weeklyReport.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(weeklyReportService.updateWeeklyReport(weeklyReport));
    }

    /**
     * 删除周报简报
     */
    @Log(title = "周报简报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(weeklyReportService.logicDeleteWeeklyReport(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }


    /**
     * 获取周报简报详细信息
     */
    /*@PreAuthorize("@ss.hasPermi('weeklyReport:weeklyReport:query')")
    @GetMapping(value = "/getInfoFor")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(weeklyReportService.selectWeeklyReportById(id));
    }*/

}
